package com.aaa.three.service.impl;

import com.aaa.three.mapper.PersonalInfoMapper;
import com.aaa.three.pojo.domain.PersonalQuery;
import com.aaa.three.pojo.domain.UserEmp;
import com.aaa.three.pojo.query.PersonalQueryy;
import com.aaa.three.result.AjaxResult;
import com.aaa.three.service.PersonalInfoService;
import com.aaa.three.sysconst.UserConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;

/**
 * @Author:lyq
 * @Date:2022/2/2021:06
 */
@Service
public class PersonalInfoServiceImpl implements PersonalInfoService {

    @Autowired
    private HttpSession session;
    @Autowired
    private PersonalInfoMapper personalInfoMapper;
    @Override
    public AjaxResult getPersonalInfo() {
        UserEmp userEmp = (UserEmp) session.getAttribute(UserConst.USER_IN_SESSION);
        Integer id = userEmp.getId();
     PersonalQuery personalQuery =personalInfoMapper.getPersonalInfo(id);
     return AjaxResult.success(personalQuery);
    }

    @Override
    public AjaxResult get(Integer id) {
        PersonalQuery s=personalInfoMapper.getID(id);
        return AjaxResult.success(s);
    }

    @Override
    public AjaxResult update(PersonalQuery query) {
      int i=  personalInfoMapper.update(query);
      return AjaxResult.success();
    }

    @Override
    public AjaxResult query(PersonalQueryy personalQueryy) {
        List<PersonalQuery> personalQueryList=personalInfoMapper.query(personalQueryy);
      Long aLong  =  personalInfoMapper.queryStudentTotal(personalQueryy);
        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();

        objectObjectHashMap.put("currentData",personalQueryList);
        objectObjectHashMap.put("totalCount",aLong);

        return AjaxResult.success(objectObjectHashMap);
    }



}
